/*
 * @Author: Dufen~123 dufen.0
 * @Date: 2024-12-26 17:49:11
 * @LastEditors: Dufen~123 dufen.0
 * @LastEditTime: 2024-12-27 16:11:25
 * @FilePath: \my-app\src\pages\newPage\components\BarChart.js
 * @Description: 
 */
import React, { useEffect, useRef } from 'react';
import * as echarts from 'echarts';

const BarChart = () => {
  const chartRef = useRef(null);

  useEffect(() => {
    if (chartRef.current) {
      const chart = echarts.init(chartRef.current);

      const option = {
        title: {
          text: '柱状图示例'
        },
        tooltip: {},
        xAxis: {
          data: ['A', 'B', 'C', 'D', 'E']
        },
        yAxis: {},
        series: [{
          name: '销量',
          type: 'bar',
          data: [5, 20, 36, 10, 10]
        }]
      };

      chart.setOption(option);
    }
  }, []);

  return <div ref={chartRef} style={{ width: '600px', height: '350px' }}></div>;
};

export default BarChart;
